package com.nuanshui.heatedloan.baseservice.service;

import com.alibaba.fastjson.JSON;
import com.nuanshui.framework.springContext.SpringPropertiesUtil;
import com.nuanshui.heatedloan.baseservice.constant.MediaTextStyle;
import com.nuanshui.heatedloan.baseservice.constant.String2MediaTextConverType;
import com.nuanshui.heatedloan.baseservice.facade.String2MediaTextConvert;
import com.nuanshui.heatedloan.baseservice.form.MediaForm;
import com.nuanshui.heatedloan.baseservice.model.Media;
import com.nuanshui.heatedloan.baseservice.vo.MediaVO;
import com.nuanshui.heatedloan.constant.ServiceConstant;
import org.springframework.stereotype.Service;


@Service(ServiceConstant.STRING2MEDIATEXTCONVERT)
public class String2MediaTextConvertImpl implements String2MediaTextConvert{
	
	@Override
	public MediaForm string2MediaFormConvert(String mediaStr, int type) {
		return (MediaForm) convert(mediaStr, type, new MediaForm());
	}

	@Override
	public MediaVO string2MediaVOConvert(String mediaStr, int type) {
		return (MediaVO) convert(mediaStr, type, new MediaVO());
	}

	@Override
	public Media convert(String mediaStr, Object param, Media media) {
		int type = (int) param;
		media.setContentText(mediaStr);
		media.setType(0);
		switch (type) {
		case String2MediaTextConverType.CONVERT_TYPE_NOSTYLE:
			break;
		case String2MediaTextConverType.CONVERT_TYPE_EXHIBITIONROOMTITLESTYLE:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("exhibitionRoomTitleStyle"));
			media.setSortNum(1);
			break;
		case String2MediaTextConverType.CONVERT_TYPE_EXHIBITIONROOMDISCRIPTIONSTYLE:
			media.setContentText(mediaStr);
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("exhibitionRoomDiscriptionStyle"));
			media.setSortNum(2);
			break;
		case String2MediaTextConverType.CONVERT_TYPE_EXHIBITIONROOMTIMESTYLE:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("exhibitionRoomTimeStyle"));
			media.setSortNum(3);
			break;
		case String2MediaTextConverType.PARAGRAPHICONURLSTYLE:
			MediaTextStyle mediaTextStyle = JSON.parseObject(media.getStyle(), MediaTextStyle.class);
			mediaTextStyle.setParagraphIconUrl(SpringPropertiesUtil.getPropertiestValue("paragraphIconUrl"));
			mediaTextStyle.setParagraphIconType(null);//将段落样式消除
			media.setStyle(JSON.toJSONString(mediaTextStyle));
			break;
		case String2MediaTextConverType.CONVERT_TYPE_EXHIBITIONTITLESTYLE:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("exhibitionTitleStyle"));
			break;
		case String2MediaTextConverType.CONVERT_TYPE_EXHIBITIONFROMSTYLE:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("exhibitionFromStyle"));
			break;
		case String2MediaTextConverType.CONVERT_TYPE_EXHIBITIONROOMDISCRIPTIONTITLESTYLE:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("exhibitionRoomDiscriptionTitleStyle"));
			break;
		case String2MediaTextConverType.CONVERT_TYPE_MUSEUMACTIVITY_INTRODUCING:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("museumactivityIntroducingStyle"));
			break;
		case String2MediaTextConverType.CONVERT_TYPE_COMPETITION_TITLE:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("game.competitionTitleStyle"));
			break;
		case String2MediaTextConverType.CONVERT_TYPE_COMPETITION_START_DATE:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("game.competitionStartDateStyle"));
			break;
		case String2MediaTextConverType.CONVERT_TYPE_COMPETITION_HOST_UNIT:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("game.competitionHostUnitStyle"));
			break;
		case String2MediaTextConverType.CONVERT_TYPE_PROJECT_TITLE:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("game.projectTitleStyle"));
			break;
		case String2MediaTextConverType.CONVERT_TYPE_PROJECT_TICKET_PRICE:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("game.projectTicketPriceStyle"));
			break;
		case String2MediaTextConverType.CONVERT_TYPE_FIT_PEOPLE:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("game.projectFitpeopleStyle"));
			break;
		case String2MediaTextConverType.CONVERT_TYPE_PEOPLE_SEX:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("game.projectPeopleSexStyle"));
			break;
		case String2MediaTextConverType.CONVERT_TYPE_TEAM_LIMIT_PEOPLE:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("game.projectTeamLimitpeopleStyle"));
			break;
		case String2MediaTextConverType.CONVERT_TYPE_COMPETITION_END_DATE:
			media.setStyle(SpringPropertiesUtil.getPropertiestValue("game.competitionEndDateStyle"));
			break;
		}
		return media;
	}

	@Override
	public Media convert(String mediaStr, Object param) {
		Media form = new Media();
		return convert(mediaStr, param, form);
	}
	
	@Override
	public String reConvert(Media media, Object param, String s) {
		return null;
	}
	
	@Override
	public String reConvert(Media t, Object param) {
		return null;
	}

	@Override
	public MediaForm paragraphString2MediaFormConvert(String mediaStr, String paragraphPrefix) {
		MediaForm form = new MediaForm();
		form.setStyle(paragraphPrefix);
		return (MediaForm) convert(mediaStr, String2MediaTextConverType.PARAGRAPHICONURLSTYLE, form);
	}
}
